//绑定支付宝弹窗

import React from 'react';
import CommonModal from '@/components/CommonModal';
import { getCurrentUser } from '@/utils/authority';
import { Base64 } from 'js-base64';
import IconFont from '@/components/IconFont'
import styles from './ZfbModal.module.less';

export default ({ ZfbModalSwitch, ZfbModalNo, path }) => {

    //授权支付宝
    const zfbAuth = function () {
        let url = 'https://auth.alipay.com/login/index.htm?goto='
        let url1 = ''
        if (path == 'zx') {
            // url1 = Base64.encode(window.location.href + '?switch=true&&name=zx' + '|' + getCurrentUser().uuid + '|' + (ZFB_URL || ''))
            url1 = Base64.encode(window.location.origin +'/#/account/safety' + '?switch=true&&name=zx' + '|' + getCurrentUser().uuid + '|' + (ZFB_URL || ''))

        } else if (path == 'lb') {
            url1 = Base64.encode(window.location.origin +'/#/account/safety' + '?switch=true&&name=lb' + '|' + getCurrentUser().uuid + '|' + (ZFB_URL || ''))
        }
        let url2 = encodeURIComponent('https://openauth.alipay.com/oauth2/appToAppAuth.htm?redirect_uri=http://api-pl.zhaojiafang.com/api/aliauthnotify&app_id=2019112169351392&state=' + url1)
        window.location.href = url + url2
    }

    return (
        <CommonModal
            title="绑定支付宝"
            visible={ZfbModalSwitch}
            onOk={zfbAuth}
            onCancel={ZfbModalNo}
        >
            <p className={styles.zfbiconbox}>
                <IconFont className={styles.zfbicon} type='iconzhifubao' style={{ fontSize: '50px' }}></IconFont>
            </p>
            <p className={styles.zfbiconbox}>是否登录并授权成功？</p>
        </CommonModal>
    )
}